home *** CD-ROM | disk | FTP | other *** search
/ Aminet 15 / Aminet 15 - Nov 1996.iso / Aminet / comm / tcp / EasyAmiTCP20.lha / EasyGo.rexx < prev   
OS/2 REXX Batch file  |  1996-03-31  |  6KB  |  192 lines

  1. /* $VER: EasyAmiTCP v2.0ß (31.03.96) 6198
  2. ** Copyright (c) 1996 Arne Seime
  3. **
  4. */
  5.  
  6. options results
  7. signal on error
  8.  
  9. address EASYAMITCP20
  10.  
  11. /* Get ALL info from GUI */
  12. /*Names*/
  13. string ID DEFNAME
  14. fields.username = result
  15. string ID REALNAME
  16. fields.realname = result
  17. slider ID USERID
  18. fields.userid = result
  19. slider ID GROUPID
  20. fields.groupid = result
  21. string ID HOME
  22. fields.home = result
  23.  
  24. /* IP-adressing */
  25. string ID IPADRESS
  26. fields.ipaddress = result
  27. string ID NETMASK
  28. fields.netmask = result
  29. string ID NAMESERVER
  30. fields.nameserver = result
  31. string ID GATEWAY
  32. fields.gateway = result
  33. string ID DOMAIN
  34. fields.domain = result
  35.  
  36. /*Serial*/
  37. popasl ID SERIAL 
  38. fields.serial = result
  39. slider ID UNIT
  40. fields.serunit = result
  41. cycle ID BAUD
  42. fields.baud = result
  43. slider ID MTU
  44. fields.mtu = result
  45. popasl ID DIALSCRIPT
  46. fields.dialscript = result
  47.  
  48. /*PPP options */
  49. check ID CD
  50. fields.pcd = result
  51. check ID CTS
  52. fields.handshake = result
  53. check ID NOEOF
  54. fields.eof = result
  55. check ID USEODU
  56. fields.odu = result
  57. check ID SHARED
  58. fields.shared = result
  59.  
  60. call getclip(defname)
  61. option.defname = result
  62. call getclip(password)
  63. XPASSWD = result
  64.  
  65.     if fields.username ~= "" then
  66.     do
  67.         
  68. /* Enter Amitcp:db/resolv.conf */
  69.     if exists('Amitcp:db/resolv.conf') then
  70.     do
  71.         gauge ID ACTION LEVEL 20 '"Updating nameserver - adding" fields.domain "("fields.nameserver")"%ld'
  72.         Address command 'Delete >NIL: Amitcp:db/resolv.conf.old'
  73.         Address command 'Rename >NIL: Amitcp:db/resolv.conf Amitcp:db/resolv.conf.old'
  74.         OK = open(resolv,'Amitcp:db/resolv.conf',w)
  75.         Call Writeln(resolv,'; Domain names')
  76.         Call Writeln(resolv,'DOMAIN' fields.domain)
  77.         Call Writeln(resolv,'; Nameservers')
  78.         Call Writeln(resolv,'NAMESERVER' fields.nameserver)
  79.         Call Close(resolv)
  80.     end
  81. /* Do changes to StartNET commando */
  82.  
  83.         gauge ID ACTION LEVEL 40 LABEL "Updating PPP options..."
  84.         If fields.pcd = "1" then option.pcd = CD
  85.         else option.pcd = ""
  86.         if fields.handshake = "1" then option.handshake = 7WIRE
  87.         else option.handshake = ""
  88.         if fields.eof = "1" then option.eof = NOEOFMODE
  89.         else option.eof = ""
  90.         if fields.odu = "1" then option.odu = USEODU
  91.         else option.odu = ""
  92.         if fields.shared = "1" then option.shared = SHARED
  93.         else option.shared = ""
  94.  
  95.         Sana2Opts = '.def S2OPT "'fields.serial fields.serunit fields.baud fields.ipaddress option.pcd option.handshake 'MTU='fields.mtu option.odu option.eof 'DIALSCRIPT='fields.dialscript option.shared'"'
  96.  
  97.         /* Edit old / create new account */
  98.         address command 'Copy >NIL: AmiTCP:db/passwd T:'
  99.         if open(pwd,'T:passwd') then
  100.         do
  101.             ulenght= length(fields.username)
  102.             do while ~eof(pwd)
  103.                 line = readln(pwd)
  104.                 if left(line,(ulenght)) = fields.username then
  105.                 do
  106.                     gauge ID ACTION LEVEL 60 LABEL "Updating user" fields.username
  107.                     option.defname = fields.username
  108.                     OK = Open(opwd,'T:passwd')
  109.                     if rc ~=0 then exit
  110.                     OK = Open(npwd,'T:passwd.new',w)
  111.                     if rc ~=0 then exit
  112.                     Do while ~eof(opwd)
  113.                         pline = readln(opwd)
  114.                         if left(pline,length(fields.username)+1) = (fields.username'|') then pline = (fields.username'|'XPasswd'|'fields.userid'|'fields.groupid'|'fields.realname'|'fields.home'|shell')
  115.                         If pline ~= "" then Call Writeln(npwd,pline)
  116.                     end
  117.                     Call Close(npwd)
  118.                     Call Close(opwd)
  119.                     Address command 'Delete >NIL: Amitcp:db/passwd.old'
  120.                     Address command 'Rename >NIL: Amitcp:db/passwd Amitcp:db/passwd.old'
  121.                     Address command 'Copy >NIL: T:passwd.new Amitcp:db/'
  122.                     Address command 'Rename >NIL: Amitcp:db/passwd.new Amitcp:db/passwd'
  123.                     Call Close(pwd)
  124.                     if exists('Amitcp:Bin/startnet') then
  125.                     do
  126.                         gauge ID ACTION LEVEL 80 LABEL "Updating IP-addresses..."
  127.                         OK = Open(snet,'Amitcp:Bin/Startnet')
  128.                         OK = Open(wnet,'T:StartNET',w)
  129.                         do while ~eof(snet)
  130.                             line = readln(snet)
  131.                             if left(line,9) = '.def MASK' then line = ".def MASK" fields.netmask
  132.                             if left(line,7) = '.def GW' then line = ".def GW" fields.gateway
  133.                             if left(line,9) = '.def USER' then line = ".def USER" option.defname
  134.                             if left(line,10) = '.def S2OPT' then line = Sana2Opts
  135.                             Call Writeln(wnet,line)
  136.                         end            
  137.                     Call Close(wnet)
  138.                     Call Close(snet)
  139.                     Address command "Delete >NIL: AmiTCP:Bin/Startnet"
  140.                     Address command "Copy >NIL: T:Startnet Amitcp:bin"
  141.                     Address command "Protect Amitcp:bin/startnet +s"
  142.                     end
  143.                     gauge ID ACTION LEVEL 100 LABEL "Done."
  144.                     RETURN 0
  145.                 end
  146.             end
  147.             OK = open(Xpwd,'T:passwd',a)
  148.             gauge ID ACTION LEVEL 60 LABEL "Adding new user" fields.username "("fields.realname")"
  149.             Call Writeln(Xpwd,fields.username'||'fields.userid'|'fields.groupid'|'fields.realname'|'fields.home'|shell')
  150.             Call Close(Xpwd)
  151.             Address command 'Delete >NIL: Amitcp:db/passwd.old'
  152.             Address command 'Rename >NIL: Amitcp:db/passwd Amitcp:db/passwd.old'
  153.             Address command 'Copy >NIL: T:passwd Amitcp:db/'
  154.             OK = open(Execpwd,'T:ExecuteMe',w)
  155.             Call Writeln(Execpwd,'Echo ""')
  156.             Call Writeln(Execpwd,'Failat 21')
  157.             Call Writeln(Execpwd,'Big 0 11 640 100')
  158.             Call Writeln(Execpwd,'Avail >NIL: Flush')
  159.             Call Writeln(Execpwd,'Failat 11')
  160.             Call Writeln(Execpwd,'Amitcp:Bin/login' fields.username)
  161.             Call Writeln(Execpwd,'Amitcp:bin/passwd' fields.username)
  162.             Call Writeln(Execpwd,'Echo ""')
  163.             Call Writeln(Execpwd,'Echo Please close the window.')
  164.             Call Close(Execpwd)
  165.             Address command 'Execute T:ExecuteMe'
  166.             Address command 'Delete >NIL: T:ExecuteMe'
  167.             option.defname = fields.username
  168.         end
  169.     end
  170.     if exists('Amitcp:Bin/startnet') then
  171.     do
  172.         gauge ID ACTION LEVEL 80 LABEL "Updating IP-addresses..."
  173.         OK = Open(snet,'Amitcp:Bin/Startnet')
  174.         OK = Open(wnet,'T:StartNET',w)
  175.         do while ~eof(snet)
  176.             line = readln(snet)
  177.             if left(line,9) = '.def MASK' then line = ".def MASK" fields.netmask
  178.             if left(line,7) = '.def GW' then line = ".def GW" fields.gateway
  179.             if left(line,9) = '.def USER' then line = ".def USER" option.defname
  180.             if left(line,10) = '.def S2OPT' then line = Sana2Opts
  181.             Call Writeln(wnet,line)
  182.         end            
  183.         Call Close(wnet)
  184.         Call Close(snet)
  185.         Address command "Delete >NIL: AmiTCP:Bin/Startnet"
  186.         Address command "Copy >NIL: T:Startnet Amitcp:bin"
  187.         Address command "Protect Amitcp:bin/startnet +s"
  188.     end
  189.     gauge ID ACTION LEVEL 100 LABEL "Done."
  190.  
  191. exit
  192.